/*    */ package com.zimbra.cs.lmtpserver.utils;
/*    */ 
/*    */ import com.zimbra.cs.lmtpserver.LmtpAddress;
/*    */ import java.io.BufferedReader;
/*    */ import java.io.IOException;
/*    */ import java.io.InputStreamReader;
/*    */ import java.io.PrintStream;
/*    */ import java.util.Iterator;
/*    */ import java.util.Map;
/*    */ import java.util.Map.Entry;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class LmtpAddressTester
/*    */ {
/*    */   public static void main(String[] args)
/*    */     throws IOException
/*    */   {
/* 31 */     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
/*    */     
/* 33 */     int i = 0;
/* 34 */     String line; while ((line = in.readLine()) != null) {
/* 35 */       i++;
/*    */       
/* 37 */       if ((!line.startsWith("#")) && (line.length() != 0))
/*    */       {
/*    */ 
/*    */ 
/* 41 */         int colon = line.indexOf(':');
/* 42 */         if (colon < 0) {
/* 43 */           System.err.println("missing colon:line " + i + ":" + line);
/*    */         }
/*    */         else {
/* 46 */           String result = line.substring(0, colon);
/* 47 */           String input = line.substring(colon + 1);
/*    */           
/*    */           boolean validity;
/* 50 */           if ("+".equals(result)) {
/* 51 */             validity = true; } else { boolean validity;
/* 52 */             if ("-".equals(result)) {
/* 53 */               validity = false;
/*    */             } else {
/* 55 */               System.err.println("missing result:line " + i + ":" + line);
/* 56 */               continue;
/*    */             } }
/*    */           boolean validity;
/* 59 */           if (args.length == 0) {
/* 60 */             args = new String[] { "BODY", "SIZE" };
/*    */           }
/* 62 */           if (test(input, args) != validity)
/* 63 */             System.err.println("incorrect result:line " + i + ":" + line);
/*    */         }
/*    */       }
/*    */     }
/*    */   }
/*    */   
/* 69 */   private static boolean test(String line, String[] allowedParams) { System.out.println("==>" + line + "<==");
/* 70 */     LmtpAddress addr = new LmtpAddress(line, allowedParams, "+");
/* 71 */     System.out.println("  valid=" + addr.isValid());
/* 72 */     int i; Iterator it; if (addr.isValid()) {
/* 73 */       System.out.println("  local-part=/" + addr.getLocalPart() + "/");
/* 74 */       System.out.println("  normalized-local=/" + addr.getNormalizedLocalPart() + "/");
/* 75 */       System.out.println("  domain-part=/" + addr.getDomainPart() + "/");
/* 76 */       Map params = addr.getParameters();
/* 77 */       i = 0;
/* 78 */       for (it = params.entrySet().iterator(); it.hasNext();) {
/* 79 */         Map.Entry e = (Map.Entry)it.next();
/* 80 */         String key = (String)e.getKey();
/* 81 */         String val = (String)e.getValue();
/* 82 */         System.out.println("  [" + i + "] key=/" + key + "/ val=/" + val + "/");
/* 83 */         i++;
/*    */       }
/*    */     }
/* 86 */     return addr.isValid();
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/lmtpserver/utils/LmtpAddressTester.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */